package top.frsf.mqttconsumerapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.frsf.mqttconsumerapp.config.MqttConsumerConfig;

@RestController
public class ReceiveController {

    @Autowired
    private MqttConsumerConfig client;

    @Value("${mqtt.client.id}")
    private String clientId;

    @GetMapping("connect")
    public String connect() {
        client.connect();
        return client + "连接到服务器";
    }

    @GetMapping("disconnect")
    public String disconnect() {
        client.disconnect();
        return clientId + "与服务器断开连接";
    }
}
